package com.tangruojie.optional;

import com.tangruojie.entity.Author;
import com.tangruojie.stream.StreamDemoTest;

import java.util.List;
import java.util.Optional;

/**
 * 判断存在 isPresent
 */
public class OptionalDemo05 {

    public static void main(String[] args) {

        List<Author> authors = StreamDemoTest.getAuthors();
        Optional<Author> optionalAuthor = Optional.ofNullable(authors.get(0));
        optionalAuthor.ifPresent(author -> System.out.println(author.getName()));

    }

}
